@livekit/agents 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ipc/proc_job_executor.cjs +1 -1
- package/dist/ipc/proc_job_executor.cjs.map +1 -1
- package/dist/ipc/proc_job_executor.d.ts.map +1 -1
- package/dist/ipc/proc_job_executor.js +1 -1
- package/dist/ipc/proc_job_executor.js.map +1 -1
- package/dist/metrics/base.cjs +2 -2
- package/dist/metrics/base.cjs.map +1 -1
- package/dist/metrics/base.d.ts +1 -1
- package/dist/metrics/base.d.ts.map +1 -1
- package/dist/metrics/base.js +2 -2
- package/dist/metrics/base.js.map +1 -1
- package/package.json +1 -1
- package/src/ipc/proc_job_executor.ts +3 -1
- package/src/metrics/base.ts +7 -10
|
@@ -112,7 +112,7 @@ class ProcJobExecutor extends import_job_executor.JobExecutor {
|
|
|
112
112
|
this.#proc.on("message", listener);
|
|
113
113
|
this.#proc.on("error", (err) => {
|
|
114
114
|
if (this.#closing) return;
|
|
115
|
-
this.#logger.child({ err }).warn("job process exited unexpectedly");
|
|
115
|
+
this.#logger.child({ err }).warn("job process exited unexpectedly; this likely means the error above caused a crash");
|
|
116
116
|
clearTimeout(this.#pongTimeout);
|
|
117
117
|
clearInterval(this.#pingInterval);
|
|
118
118
|
this.#join.resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ipc/proc_job_executor.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ChildProcess } from 'node:child_process';\nimport { once } from 'node:events';\nimport type { RunningJobInfo } from '../job.js';\nimport { log, loggerOptions } from '../log.js';\nimport { Future } from '../utils.js';\nimport type { ProcOpts } from './job_executor.js';\nimport { JobExecutor } from './job_executor.js';\nimport type { IPCMessage } from './message.js';\n\nexport class ProcJobExecutor extends JobExecutor {\n #opts: ProcOpts;\n #started = false;\n #closing = false;\n #runningJob?: RunningJobInfo = undefined;\n #proc?: ChildProcess;\n #pingInterval?: ReturnType<typeof setInterval>;\n #pongTimeout?: ReturnType<typeof setTimeout>;\n #init = new Future();\n #join = new Future();\n #logger = log().child({ runningJob: this.#runningJob });\n\n constructor(agent: string, initializeTimeout: number, closeTimeout: number) {\n super();\n this.#opts = {\n agent,\n initializeTimeout,\n closeTimeout,\n };\n }\n\n get started(): boolean {\n return this.#started;\n }\n\n get runningJob(): RunningJobInfo | undefined {\n return this.#runningJob;\n }\n\n async start() {\n if (this.#started) {\n throw new Error('runner already started');\n } else if (this.#closing) {\n throw new Error('runner is closed');\n }\n\n this.#proc = await import('./job_main.js').then((m) =>\n m.runProcess({\n agentFile: this.#opts.agent,\n }),\n );\n\n this.#started = true;\n this.run();\n }\n\n async run() {\n await this.#init.await;\n\n this.#pingInterval = setInterval(() => {\n this.#proc!.send({ case: 'pingRequest', value: { timestamp: Date.now() } });\n }, this.PING_INTERVAL);\n\n this.#pongTimeout = setTimeout(() => {\n this.#logger.warn('job is unresponsive');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#proc!.kill();\n this.#join.resolve();\n }, this.PING_TIMEOUT);\n\n const listener = (msg: IPCMessage) => {\n switch (msg.case) {\n case 'pongResponse': {\n const delay = Date.now() - msg.value.timestamp;\n if (delay > this.HIGH_PING_THRESHOLD) {\n this.#logger.child({ delay }).warn('job executor is unresponsive');\n }\n this.#pongTimeout?.refresh();\n break;\n }\n case 'exiting': {\n this.#logger.child({ reason: msg.value.reason }).debug('job exiting');\n break;\n }\n case 'done': {\n this.#closing = true;\n this.#proc!.off('message', listener);\n this.#join.resolve();\n break;\n }\n }\n };\n this.#proc!.on('message', listener);\n this.#proc!.on('error', (err) => {\n if (this.#closing) return;\n this.#logger.child({ err }).warn('job process exited unexpectedly');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#join.resolve();\n });\n\n await this.#join.await;\n }\n\n async join() {\n if (!this.#started) {\n throw new Error('runner not started');\n }\n\n await this.#join.await;\n }\n\n async initialize() {\n const timer = setTimeout(() => {\n const err = new Error('runner initialization timed out');\n this.#init.reject(err);\n throw err;\n }, this.#opts.initializeTimeout);\n this.#proc!.send({ case: 'initializeRequest', value: { loggerOptions } });\n await once(this.#proc!, 'message').then(([msg]: IPCMessage[]) => {\n clearTimeout(timer);\n if (msg!.case !== 'initializeResponse') {\n throw new Error('first message must be InitializeResponse');\n }\n });\n this.#init.resolve();\n }\n\n async close() {\n if (!this.#started) {\n return;\n }\n this.#closing = true;\n\n if (!this.#runningJob) {\n this.#proc!.kill();\n this.#join.resolve();\n }\n\n this.#proc!.send({ case: 'shutdownRequest' });\n\n const timer = setTimeout(() => {\n this.#logger.error('job shutdown is taking too much time');\n }, this.#opts.closeTimeout);\n await this.#join.await.then(() => {\n clearTimeout(timer);\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n });\n }\n\n async launchJob(info: RunningJobInfo) {\n if (this.#runningJob) {\n throw new Error('executor already has a running job');\n }\n this.#runningJob = info;\n this.#proc!.send({ case: 'startJobRequest', value: { runningJob: info } });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAAqB;AAErB,iBAAmC;AACnC,mBAAuB;AAEvB,0BAA4B;AAGrB,MAAM,wBAAwB,gCAAY;AAAA,EAC/C;AAAA,EACA,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAA+B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,IAAI,oBAAO;AAAA,EACnB,QAAQ,IAAI,oBAAO;AAAA,EACnB,cAAU,gBAAI,EAAE,MAAM,EAAE,YAAY,KAAK,YAAY,CAAC;AAAA,EAEtD,YAAY,OAAe,mBAA2B,cAAsB;AAC1E,UAAM;AACN,SAAK,QAAQ;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;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,EAAE,MAAM,aAAa;AACpE;AAAA,QACF;AAAA,QACA,KAAK,QAAQ;AACX,eAAK,WAAW;AAChB,eAAK,MAAO,IAAI,WAAW,QAAQ;AACnC,eAAK,MAAM,QAAQ;AACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,SAAK,MAAO,GAAG,WAAW,QAAQ;AAClC,SAAK,MAAO,GAAG,SAAS,CAAC,QAAQ;AAC/B,UAAI,KAAK,SAAU;AACnB,WAAK,
|
|
1
|
+
{"version":3,"sources":["../../src/ipc/proc_job_executor.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ChildProcess } from 'node:child_process';\nimport { once } from 'node:events';\nimport type { RunningJobInfo } from '../job.js';\nimport { log, loggerOptions } from '../log.js';\nimport { Future } from '../utils.js';\nimport type { ProcOpts } from './job_executor.js';\nimport { JobExecutor } from './job_executor.js';\nimport type { IPCMessage } from './message.js';\n\nexport class ProcJobExecutor extends JobExecutor {\n #opts: ProcOpts;\n #started = false;\n #closing = false;\n #runningJob?: RunningJobInfo = undefined;\n #proc?: ChildProcess;\n #pingInterval?: ReturnType<typeof setInterval>;\n #pongTimeout?: ReturnType<typeof setTimeout>;\n #init = new Future();\n #join = new Future();\n #logger = log().child({ runningJob: this.#runningJob });\n\n constructor(agent: string, initializeTimeout: number, closeTimeout: number) {\n super();\n this.#opts = {\n agent,\n initializeTimeout,\n closeTimeout,\n };\n }\n\n get started(): boolean {\n return this.#started;\n }\n\n get runningJob(): RunningJobInfo | undefined {\n return this.#runningJob;\n }\n\n async start() {\n if (this.#started) {\n throw new Error('runner already started');\n } else if (this.#closing) {\n throw new Error('runner is closed');\n }\n\n this.#proc = await import('./job_main.js').then((m) =>\n m.runProcess({\n agentFile: this.#opts.agent,\n }),\n );\n\n this.#started = true;\n this.run();\n }\n\n async run() {\n await this.#init.await;\n\n this.#pingInterval = setInterval(() => {\n this.#proc!.send({ case: 'pingRequest', value: { timestamp: Date.now() } });\n }, this.PING_INTERVAL);\n\n this.#pongTimeout = setTimeout(() => {\n this.#logger.warn('job is unresponsive');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#proc!.kill();\n this.#join.resolve();\n }, this.PING_TIMEOUT);\n\n const listener = (msg: IPCMessage) => {\n switch (msg.case) {\n case 'pongResponse': {\n const delay = Date.now() - msg.value.timestamp;\n if (delay > this.HIGH_PING_THRESHOLD) {\n this.#logger.child({ delay }).warn('job executor is unresponsive');\n }\n this.#pongTimeout?.refresh();\n break;\n }\n case 'exiting': {\n this.#logger.child({ reason: msg.value.reason }).debug('job exiting');\n break;\n }\n case 'done': {\n this.#closing = true;\n this.#proc!.off('message', listener);\n this.#join.resolve();\n break;\n }\n }\n };\n this.#proc!.on('message', listener);\n this.#proc!.on('error', (err) => {\n if (this.#closing) return;\n this.#logger\n .child({ err })\n .warn('job process exited unexpectedly; this likely means the error above caused a crash');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#join.resolve();\n });\n\n await this.#join.await;\n }\n\n async join() {\n if (!this.#started) {\n throw new Error('runner not started');\n }\n\n await this.#join.await;\n }\n\n async initialize() {\n const timer = setTimeout(() => {\n const err = new Error('runner initialization timed out');\n this.#init.reject(err);\n throw err;\n }, this.#opts.initializeTimeout);\n this.#proc!.send({ case: 'initializeRequest', value: { loggerOptions } });\n await once(this.#proc!, 'message').then(([msg]: IPCMessage[]) => {\n clearTimeout(timer);\n if (msg!.case !== 'initializeResponse') {\n throw new Error('first message must be InitializeResponse');\n }\n });\n this.#init.resolve();\n }\n\n async close() {\n if (!this.#started) {\n return;\n }\n this.#closing = true;\n\n if (!this.#runningJob) {\n this.#proc!.kill();\n this.#join.resolve();\n }\n\n this.#proc!.send({ case: 'shutdownRequest' });\n\n const timer = setTimeout(() => {\n this.#logger.error('job shutdown is taking too much time');\n }, this.#opts.closeTimeout);\n await this.#join.await.then(() => {\n clearTimeout(timer);\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n });\n }\n\n async launchJob(info: RunningJobInfo) {\n if (this.#runningJob) {\n throw new Error('executor already has a running job');\n }\n this.#runningJob = info;\n this.#proc!.send({ case: 'startJobRequest', value: { runningJob: info } });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAAqB;AAErB,iBAAmC;AACnC,mBAAuB;AAEvB,0BAA4B;AAGrB,MAAM,wBAAwB,gCAAY;AAAA,EAC/C;AAAA,EACA,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAA+B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,IAAI,oBAAO;AAAA,EACnB,QAAQ,IAAI,oBAAO;AAAA,EACnB,cAAU,gBAAI,EAAE,MAAM,EAAE,YAAY,KAAK,YAAY,CAAC;AAAA,EAEtD,YAAY,OAAe,mBAA2B,cAAsB;AAC1E,UAAM;AACN,SAAK,QAAQ;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,aAAyC;AAC3C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ;AACZ,QAAI,KAAK,UAAU;AACjB,YAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C,WAAW,KAAK,UAAU;AACxB,YAAM,IAAI,MAAM,kBAAkB;AAAA,IACpC;AAEA,SAAK,QAAQ,MAAM,OAAO,eAAe,EAAE;AAAA,MAAK,CAAC,MAC/C,EAAE,WAAW;AAAA,QACX,WAAW,KAAK,MAAM;AAAA,MACxB,CAAC;AAAA,IACH;AAEA,SAAK,WAAW;AAChB,SAAK,IAAI;AAAA,EACX;AAAA,EAEA,MAAM,MAAM;AACV,UAAM,KAAK,MAAM;AAEjB,SAAK,gBAAgB,YAAY,MAAM;AACrC,W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C3E;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proc_job_executor.d.ts","sourceRoot":"","sources":["../../src/ipc/proc_job_executor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,eAAgB,SAAQ,WAAW;;gBAYlC,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAS1E,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,cAAc,GAAG,SAAS,CAE3C;IAEK,KAAK;IAiBL,GAAG;
|
|
1
|
+
{"version":3,"file":"proc_job_executor.d.ts","sourceRoot":"","sources":["../../src/ipc/proc_job_executor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,eAAgB,SAAQ,WAAW;;gBAYlC,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAS1E,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,cAAc,GAAG,SAAS,CAE3C;IAEK,KAAK;IAiBL,GAAG;IAmDH,IAAI;IAQJ,UAAU;IAgBV,KAAK;IAuBL,SAAS,CAAC,IAAI,EAAE,cAAc;CAOrC"}
|
|
@@ -79,7 +79,7 @@ class ProcJobExecutor extends JobExecutor {
|
|
|
79
79
|
this.#proc.on("message", listener);
|
|
80
80
|
this.#proc.on("error", (err) => {
|
|
81
81
|
if (this.#closing) return;
|
|
82
|
-
this.#logger.child({ err }).warn("job process exited unexpectedly");
|
|
82
|
+
this.#logger.child({ err }).warn("job process exited unexpectedly; this likely means the error above caused a crash");
|
|
83
83
|
clearTimeout(this.#pongTimeout);
|
|
84
84
|
clearInterval(this.#pingInterval);
|
|
85
85
|
this.#join.resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ipc/proc_job_executor.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ChildProcess } from 'node:child_process';\nimport { once } from 'node:events';\nimport type { RunningJobInfo } from '../job.js';\nimport { log, loggerOptions } from '../log.js';\nimport { Future } from '../utils.js';\nimport type { ProcOpts } from './job_executor.js';\nimport { JobExecutor } from './job_executor.js';\nimport type { IPCMessage } from './message.js';\n\nexport class ProcJobExecutor extends JobExecutor {\n #opts: ProcOpts;\n #started = false;\n #closing = false;\n #runningJob?: RunningJobInfo = undefined;\n #proc?: ChildProcess;\n #pingInterval?: ReturnType<typeof setInterval>;\n #pongTimeout?: ReturnType<typeof setTimeout>;\n #init = new Future();\n #join = new Future();\n #logger = log().child({ runningJob: this.#runningJob });\n\n constructor(agent: string, initializeTimeout: number, closeTimeout: number) {\n super();\n this.#opts = {\n agent,\n initializeTimeout,\n closeTimeout,\n };\n }\n\n get started(): boolean {\n return this.#started;\n }\n\n get runningJob(): RunningJobInfo | undefined {\n return this.#runningJob;\n }\n\n async start() {\n if (this.#started) {\n throw new Error('runner already started');\n } else if (this.#closing) {\n throw new Error('runner is closed');\n }\n\n this.#proc = await import('./job_main.js').then((m) =>\n m.runProcess({\n agentFile: this.#opts.agent,\n }),\n );\n\n this.#started = true;\n this.run();\n }\n\n async run() {\n await this.#init.await;\n\n this.#pingInterval = setInterval(() => {\n this.#proc!.send({ case: 'pingRequest', value: { timestamp: Date.now() } });\n }, this.PING_INTERVAL);\n\n this.#pongTimeout = setTimeout(() => {\n this.#logger.warn('job is unresponsive');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#proc!.kill();\n this.#join.resolve();\n }, this.PING_TIMEOUT);\n\n const listener = (msg: IPCMessage) => {\n switch (msg.case) {\n case 'pongResponse': {\n const delay = Date.now() - msg.value.timestamp;\n if (delay > this.HIGH_PING_THRESHOLD) {\n this.#logger.child({ delay }).warn('job executor is unresponsive');\n }\n this.#pongTimeout?.refresh();\n break;\n }\n case 'exiting': {\n this.#logger.child({ reason: msg.value.reason }).debug('job exiting');\n break;\n }\n case 'done': {\n this.#closing = true;\n this.#proc!.off('message', listener);\n this.#join.resolve();\n break;\n }\n }\n };\n this.#proc!.on('message', listener);\n this.#proc!.on('error', (err) => {\n if (this.#closing) return;\n this.#logger.child({ err }).warn('job process exited unexpectedly');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#join.resolve();\n });\n\n await this.#join.await;\n }\n\n async join() {\n if (!this.#started) {\n throw new Error('runner not started');\n }\n\n await this.#join.await;\n }\n\n async initialize() {\n const timer = setTimeout(() => {\n const err = new Error('runner initialization timed out');\n this.#init.reject(err);\n throw err;\n }, this.#opts.initializeTimeout);\n this.#proc!.send({ case: 'initializeRequest', value: { loggerOptions } });\n await once(this.#proc!, 'message').then(([msg]: IPCMessage[]) => {\n clearTimeout(timer);\n if (msg!.case !== 'initializeResponse') {\n throw new Error('first message must be InitializeResponse');\n }\n });\n this.#init.resolve();\n }\n\n async close() {\n if (!this.#started) {\n return;\n }\n this.#closing = true;\n\n if (!this.#runningJob) {\n this.#proc!.kill();\n this.#join.resolve();\n }\n\n this.#proc!.send({ case: 'shutdownRequest' });\n\n const timer = setTimeout(() => {\n this.#logger.error('job shutdown is taking too much time');\n }, this.#opts.closeTimeout);\n await this.#join.await.then(() => {\n clearTimeout(timer);\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n });\n }\n\n async launchJob(info: RunningJobInfo) {\n if (this.#runningJob) {\n throw new Error('executor already has a running job');\n }\n this.#runningJob = info;\n this.#proc!.send({ case: 'startJobRequest', value: { runningJob: info } });\n }\n}\n"],"mappings":"AAIA,SAAS,YAAY;AAErB,SAAS,KAAK,qBAA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AAM,QAAQ;AAAA,IACrB,GAAG,KAAK,YAAY;AAEpB,UAAM,WAAW,CAAC,QAAoB;AAzE1C;AA0EM,cAAQ,IAAI,MAAM;AAAA,QAChB,KAAK,gBAAgB;AACnB,gBAAM,QAAQ,KAAK,IAAI,IAAI,IAAI,MAAM;AACrC,cAAI,QAAQ,KAAK,qBAAqB;AACpC,iBAAK,QAAQ,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,8BAA8B;AAAA,UACnE;AACA,qBAAK,iBAAL,mBAAmB;AACnB;AAAA,QACF;AAAA,QACA,KAAK,WAAW;AACd,eAAK,QAAQ,MAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,CAAC,EAAE,MAAM,aAAa;AACpE;AAAA,QACF;AAAA,QACA,KAAK,QAAQ;AACX,eAAK,WAAW;AAChB,eAAK,MAAO,IAAI,WAAW,QAAQ;AACnC,eAAK,MAAM,QAAQ;AACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,SAAK,MAAO,GAAG,WAAW,QAAQ;AAClC,SAAK,MAAO,GAAG,SAAS,CAAC,QAAQ;AAC/B,UAAI,KAAK,SAAU;AACnB,WAAK,
|
|
1
|
+
{"version":3,"sources":["../../src/ipc/proc_job_executor.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { ChildProcess } from 'node:child_process';\nimport { once } from 'node:events';\nimport type { RunningJobInfo } from '../job.js';\nimport { log, loggerOptions } from '../log.js';\nimport { Future } from '../utils.js';\nimport type { ProcOpts } from './job_executor.js';\nimport { JobExecutor } from './job_executor.js';\nimport type { IPCMessage } from './message.js';\n\nexport class ProcJobExecutor extends JobExecutor {\n #opts: ProcOpts;\n #started = false;\n #closing = false;\n #runningJob?: RunningJobInfo = undefined;\n #proc?: ChildProcess;\n #pingInterval?: ReturnType<typeof setInterval>;\n #pongTimeout?: ReturnType<typeof setTimeout>;\n #init = new Future();\n #join = new Future();\n #logger = log().child({ runningJob: this.#runningJob });\n\n constructor(agent: string, initializeTimeout: number, closeTimeout: number) {\n super();\n this.#opts = {\n agent,\n initializeTimeout,\n closeTimeout,\n };\n }\n\n get started(): boolean {\n return this.#started;\n }\n\n get runningJob(): RunningJobInfo | undefined {\n return this.#runningJob;\n }\n\n async start() {\n if (this.#started) {\n throw new Error('runner already started');\n } else if (this.#closing) {\n throw new Error('runner is closed');\n }\n\n this.#proc = await import('./job_main.js').then((m) =>\n m.runProcess({\n agentFile: this.#opts.agent,\n }),\n );\n\n this.#started = true;\n this.run();\n }\n\n async run() {\n await this.#init.await;\n\n this.#pingInterval = setInterval(() => {\n this.#proc!.send({ case: 'pingRequest', value: { timestamp: Date.now() } });\n }, this.PING_INTERVAL);\n\n this.#pongTimeout = setTimeout(() => {\n this.#logger.warn('job is unresponsive');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#proc!.kill();\n this.#join.resolve();\n }, this.PING_TIMEOUT);\n\n const listener = (msg: IPCMessage) => {\n switch (msg.case) {\n case 'pongResponse': {\n const delay = Date.now() - msg.value.timestamp;\n if (delay > this.HIGH_PING_THRESHOLD) {\n this.#logger.child({ delay }).warn('job executor is unresponsive');\n }\n this.#pongTimeout?.refresh();\n break;\n }\n case 'exiting': {\n this.#logger.child({ reason: msg.value.reason }).debug('job exiting');\n break;\n }\n case 'done': {\n this.#closing = true;\n this.#proc!.off('message', listener);\n this.#join.resolve();\n break;\n }\n }\n };\n this.#proc!.on('message', listener);\n this.#proc!.on('error', (err) => {\n if (this.#closing) return;\n this.#logger\n .child({ err })\n .warn('job process exited unexpectedly; this likely means the error above caused a crash');\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n this.#join.resolve();\n });\n\n await this.#join.await;\n }\n\n async join() {\n if (!this.#started) {\n throw new Error('runner not started');\n }\n\n await this.#join.await;\n }\n\n async initialize() {\n const timer = setTimeout(() => {\n const err = new Error('runner initialization timed out');\n this.#init.reject(err);\n throw err;\n }, this.#opts.initializeTimeout);\n this.#proc!.send({ case: 'initializeRequest', value: { loggerOptions } });\n await once(this.#proc!, 'message').then(([msg]: IPCMessage[]) => {\n clearTimeout(timer);\n if (msg!.case !== 'initializeResponse') {\n throw new Error('first message must be InitializeResponse');\n }\n });\n this.#init.resolve();\n }\n\n async close() {\n if (!this.#started) {\n return;\n }\n this.#closing = true;\n\n if (!this.#runningJob) {\n this.#proc!.kill();\n this.#join.resolve();\n }\n\n this.#proc!.send({ case: 'shutdownRequest' });\n\n const timer = setTimeout(() => {\n this.#logger.error('job shutdown is taking too much time');\n }, this.#opts.closeTimeout);\n await this.#join.await.then(() => {\n clearTimeout(timer);\n clearTimeout(this.#pongTimeout);\n clearInterval(this.#pingInterval);\n });\n }\n\n async launchJob(info: RunningJobInfo) {\n if (this.#runningJob) {\n throw new Error('executor already has a running job');\n }\n this.#runningJob = info;\n this.#proc!.send({ case: 'startJobRequest', value: { runningJob: info } });\n }\n}\n"],"mappings":"AAIA,SAAS,YAAY;AAErB,SAAS,KAAK,qBAAqB;AACnC,SAAS,cAAc;AAEvB,SAAS,mBAAmB;AAGrB,MAAM,wBAAwB,YAAY;AAAA,EAC/C;AAAA,EACA,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAA+B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,IAAI,OAAO;AAAA,EACnB,QAAQ,IAAI,OAAO;AAAA,EACnB,UAAU,IAAI,EAAE,MAAM,EAAE,YAAY,KAAK,YAAY,CAAC;AAAA,EAEtD,YAAY,OAAe,mBAA2B,cAAsB;AAC1E,UAAM;AACN,SAAK,QAAQ;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,aAAyC;AAC3C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ;AACZ,QAAI,KAAK,UAAU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IAC3D,GAAG,KAAK,MAAM,YAAY;AAC1B,UAAM,KAAK,MAAM,MAAM,KAAK,MAAM;AAChC,mBAAa,KAAK;AAClB,mBAAa,KAAK,YAAY;AAC9B,oBAAc,KAAK,aAAa;AAAA,IAClC,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,UAAU,MAAsB;AACpC,QAAI,KAAK,aAAa;AACpB,YAAM,IAAI,MAAM,oCAAoC;AAAA,IACtD;AACA,SAAK,cAAc;AACnB,SAAK,MAAO,KAAK,EAAE,MAAM,mBAAmB,OAAO,EAAE,YAAY,KAAK,EAAE,CAAC;AAAA,EAC3E;AACF;","names":[]}
|
package/dist/metrics/base.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/metrics/base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface LLMMetrics {\n requestId: string;\n timestamp: number;\n ttft: number;\n duration: number;\n label: string;\n cancelled: boolean;\n completionTokens: number;\n promptTokens: number;\n totalTokens: number;\n tokensPerSecond: number;\n error?: Error;\n}\n\nexport interface STTMetrics {\n requestId: string;\n timestamp: number;\n duration: number;\n label: string;\n audioDuration: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface TTSMetrics {\n requestId: string;\n timestamp: number;\n ttfb: number;\n duration: number;\n label: string;\n audioDuration: number;\n cancelled: boolean;\n charactersCount: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface VADMetrics {\n timestamp: number;\n idleTime: number;\n inferenceDurationTotal: number;\n inferenceCount: number;\n label: string;\n}\n\nexport interface PipelineEOUMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n /** Timestamp of when the event was recorded */\n timestamp: number;\n /** Amount of time between the end of speech from VAD and the decision to end the user's turn */\n endOfUtteranceDelay: number;\n /**\n * Time taken to obtain the transcript after the end of the user's speech.\n *\n * @remarks\n * May be 0 if the transcript was already available.\n */\n transcriptionDelay: number;\n}\n\nexport interface PipelineLLMMetrics extends LLMMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport interface PipelineTTSMetrics extends TTSMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport type PipelineSTTMetrics = STTMetrics;\nexport type PipelineVADMetrics = VADMetrics;\n\nexport class MultimodalLLMError extends Error {\n type?: string;\n reason?: string;\n code?: string;\n constructor(\n
|
|
1
|
+
{"version":3,"sources":["../../src/metrics/base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface LLMMetrics {\n requestId: string;\n timestamp: number;\n ttft: number;\n duration: number;\n label: string;\n cancelled: boolean;\n completionTokens: number;\n promptTokens: number;\n totalTokens: number;\n tokensPerSecond: number;\n error?: Error;\n}\n\nexport interface STTMetrics {\n requestId: string;\n timestamp: number;\n duration: number;\n label: string;\n audioDuration: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface TTSMetrics {\n requestId: string;\n timestamp: number;\n ttfb: number;\n duration: number;\n label: string;\n audioDuration: number;\n cancelled: boolean;\n charactersCount: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface VADMetrics {\n timestamp: number;\n idleTime: number;\n inferenceDurationTotal: number;\n inferenceCount: number;\n label: string;\n}\n\nexport interface PipelineEOUMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n /** Timestamp of when the event was recorded */\n timestamp: number;\n /** Amount of time between the end of speech from VAD and the decision to end the user's turn */\n endOfUtteranceDelay: number;\n /**\n * Time taken to obtain the transcript after the end of the user's speech.\n *\n * @remarks\n * May be 0 if the transcript was already available.\n */\n transcriptionDelay: number;\n}\n\nexport interface PipelineLLMMetrics extends LLMMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport interface PipelineTTSMetrics extends TTSMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport type PipelineSTTMetrics = STTMetrics;\nexport type PipelineVADMetrics = VADMetrics;\n\nexport class MultimodalLLMError extends Error {\n type?: string;\n reason?: string;\n code?: string;\n constructor({\n type,\n reason,\n code,\n message,\n }: { type?: string; reason?: string; code?: string; message?: string } = {}) {\n super(message);\n this.type = type;\n this.reason = reason;\n this.code = code;\n }\n}\n\nexport interface MultimodalLLMMetrics extends LLMMetrics {\n inputTokenDetails: {\n cachedTokens: number;\n textTokens: number;\n audioTokens: number;\n };\n outputTokenDetails: {\n textTokens: number;\n audioTokens: number;\n };\n}\n\nexport type AgentMetrics =\n | STTMetrics\n | LLMMetrics\n | TTSMetrics\n | VADMetrics\n | PipelineSTTMetrics\n | PipelineEOUMetrics\n | PipelineLLMMetrics\n | PipelineTTSMetrics\n | PipelineVADMetrics\n | MultimodalLLMMetrics;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoFO,MAAM,2BAA2B,MAAM;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAyE,CAAC,GAAG;AAC3E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/dist/metrics/base.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/metrics/base.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;I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AAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,iBAAiB,EAAE;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,kBAAkB,EAAE;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,CAAC"}
|
package/dist/metrics/base.js
CHANGED
package/dist/metrics/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/metrics/base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface LLMMetrics {\n requestId: string;\n timestamp: number;\n ttft: number;\n duration: number;\n label: string;\n cancelled: boolean;\n completionTokens: number;\n promptTokens: number;\n totalTokens: number;\n tokensPerSecond: number;\n error?: Error;\n}\n\nexport interface STTMetrics {\n requestId: string;\n timestamp: number;\n duration: number;\n label: string;\n audioDuration: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface TTSMetrics {\n requestId: string;\n timestamp: number;\n ttfb: number;\n duration: number;\n label: string;\n audioDuration: number;\n cancelled: boolean;\n charactersCount: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface VADMetrics {\n timestamp: number;\n idleTime: number;\n inferenceDurationTotal: number;\n inferenceCount: number;\n label: string;\n}\n\nexport interface PipelineEOUMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n /** Timestamp of when the event was recorded */\n timestamp: number;\n /** Amount of time between the end of speech from VAD and the decision to end the user's turn */\n endOfUtteranceDelay: number;\n /**\n * Time taken to obtain the transcript after the end of the user's speech.\n *\n * @remarks\n * May be 0 if the transcript was already available.\n */\n transcriptionDelay: number;\n}\n\nexport interface PipelineLLMMetrics extends LLMMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport interface PipelineTTSMetrics extends TTSMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport type PipelineSTTMetrics = STTMetrics;\nexport type PipelineVADMetrics = VADMetrics;\n\nexport class MultimodalLLMError extends Error {\n type?: string;\n reason?: string;\n code?: string;\n constructor(\n
|
|
1
|
+
{"version":3,"sources":["../../src/metrics/base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface LLMMetrics {\n requestId: string;\n timestamp: number;\n ttft: number;\n duration: number;\n label: string;\n cancelled: boolean;\n completionTokens: number;\n promptTokens: number;\n totalTokens: number;\n tokensPerSecond: number;\n error?: Error;\n}\n\nexport interface STTMetrics {\n requestId: string;\n timestamp: number;\n duration: number;\n label: string;\n audioDuration: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface TTSMetrics {\n requestId: string;\n timestamp: number;\n ttfb: number;\n duration: number;\n label: string;\n audioDuration: number;\n cancelled: boolean;\n charactersCount: number;\n streamed: boolean;\n error?: Error;\n}\n\nexport interface VADMetrics {\n timestamp: number;\n idleTime: number;\n inferenceDurationTotal: number;\n inferenceCount: number;\n label: string;\n}\n\nexport interface PipelineEOUMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n /** Timestamp of when the event was recorded */\n timestamp: number;\n /** Amount of time between the end of speech from VAD and the decision to end the user's turn */\n endOfUtteranceDelay: number;\n /**\n * Time taken to obtain the transcript after the end of the user's speech.\n *\n * @remarks\n * May be 0 if the transcript was already available.\n */\n transcriptionDelay: number;\n}\n\nexport interface PipelineLLMMetrics extends LLMMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport interface PipelineTTSMetrics extends TTSMetrics {\n /**\n * Unique identifier shared across different metrics to combine related STT, LLM, and TTS metrics\n */\n sequenceId: string;\n}\n\nexport type PipelineSTTMetrics = STTMetrics;\nexport type PipelineVADMetrics = VADMetrics;\n\nexport class MultimodalLLMError extends Error {\n type?: string;\n reason?: string;\n code?: string;\n constructor({\n type,\n reason,\n code,\n message,\n }: { type?: string; reason?: string; code?: string; message?: string } = {}) {\n super(message);\n this.type = type;\n this.reason = reason;\n this.code = code;\n }\n}\n\nexport interface MultimodalLLMMetrics extends LLMMetrics {\n inputTokenDetails: {\n cachedTokens: number;\n textTokens: number;\n audioTokens: number;\n };\n outputTokenDetails: {\n textTokens: number;\n audioTokens: number;\n };\n}\n\nexport type AgentMetrics =\n | STTMetrics\n | LLMMetrics\n | TTSMetrics\n | VADMetrics\n | PipelineSTTMetrics\n | PipelineEOUMetrics\n | PipelineLLMMetrics\n | PipelineTTSMetrics\n | PipelineVADMetrics\n | MultimodalLLMMetrics;\n"],"mappings":"AAoFO,MAAM,2BAA2B,MAAM;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAyE,CAAC,GAAG;AAC3E,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -96,7 +96,9 @@ export class ProcJobExecutor extends JobExecutor {
|
|
|
96
96
|
this.#proc!.on('message', listener);
|
|
97
97
|
this.#proc!.on('error', (err) => {
|
|
98
98
|
if (this.#closing) return;
|
|
99
|
-
this.#logger
|
|
99
|
+
this.#logger
|
|
100
|
+
.child({ err })
|
|
101
|
+
.warn('job process exited unexpectedly; this likely means the error above caused a crash');
|
|
100
102
|
clearTimeout(this.#pongTimeout);
|
|
101
103
|
clearInterval(this.#pingInterval);
|
|
102
104
|
this.#join.resolve();
|
package/src/metrics/base.ts
CHANGED
|
@@ -86,16 +86,13 @@ export class MultimodalLLMError extends Error {
|
|
|
86
86
|
type?: string;
|
|
87
87
|
reason?: string;
|
|
88
88
|
code?: string;
|
|
89
|
-
constructor(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
options?: ErrorOptions,
|
|
97
|
-
) {
|
|
98
|
-
super(message, options);
|
|
89
|
+
constructor({
|
|
90
|
+
type,
|
|
91
|
+
reason,
|
|
92
|
+
code,
|
|
93
|
+
message,
|
|
94
|
+
}: { type?: string; reason?: string; code?: string; message?: string } = {}) {
|
|
95
|
+
super(message);
|
|
99
96
|
this.type = type;
|
|
100
97
|
this.reason = reason;
|
|
101
98
|
this.code = code;
|