Skip to content

Commit 25cb636

Browse files
committed
Use pnpm instead of Bun
1 parent 1c97560 commit 25cb636

25 files changed

+1605
-69
lines changed

Diff for: .github/workflows/build.yml

+25-9
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,42 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- name: REUSE-3.0 compliance check
1515
uses: fsfe/reuse-action@v3
16-
- uses: oven-sh/setup-bun@v1
16+
- uses: pnpm/action-setup@v2
17+
with:
18+
version: 8
19+
- name: Setup node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: pnpm
24+
- name: Install dependencies
25+
run: pnpm install
1726
- name: ESLint
1827
run: |
19-
bun install
2028
cd agents
21-
bun lint
29+
pnpm lint
2230
cd ../plugins/elevenlabs
23-
bun lint
31+
pnpm lint
2432
2533
build:
2634
name: Build
2735
runs-on: ubuntu-latest
2836
needs: lint
2937
steps:
3038
- uses: actions/checkout@v4
31-
- uses: oven-sh/setup-bun@v1
32-
- name: Bun build
39+
- uses: pnpm/action-setup@v2
40+
with:
41+
version: 8
42+
- name: Setup node
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: 20
46+
cache: pnpm
47+
- name: Install dependencies
48+
run: pnpm install
49+
- name: pnpm build
3350
run: |
34-
bun install
3551
cd agents
36-
bun run build
52+
pnpm build
3753
cd ../plugins/elevenlabs
38-
bun run build
54+
pnpm build

Diff for: .reuse/dep5

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Copyright: 2024 LiveKit, Inc.
99
License: Apache-2.0
1010

1111
# global project files
12-
Files: package.json bun.lockb .prettierrc eslint.config.mjs
12+
Files: .prettierrc eslint.config.mjs pnpm-lock.yaml pnpm-workspace.yaml
1313
Copyright: 2024 LiveKit, Inc.
1414
License: Apache-2.0
1515

1616
# sub-project files
17-
Files: agents/package.json examples/package.json plugins/elevenlabs/package.json agents/tsconfig.json plugins/elevenlabs/tsconfig.json
17+
Files: agents/package.json examples/package.json plugins/elevenlabs/package.json agents/tsconfig.json plugins/elevenlabs/tsconfig.json examples/tsconfig.json
1818
Copyright: 2024 LiveKit, Inc.
1919
License: Apache-2.0

Diff for: README.md

+2-11
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,15 @@ SPDX-License-Identifier: Apache-2.0
88

99
This is a Node port of the [LiveKit Agents framework](https://livekit.io/agents), originally written in Python.
1010

11-
## Development
12-
This project builds to Node-compatible JavaScript, but is developed using the faster [Bun](https://bun.sh) JavaScript runtime. As a superset of Node, there are some caveats:
13-
14-
- Bun uses `package.json#workspaces` for monorepo handling, while pnpm uses `pnpm-workspace.yaml`. Using pnpm will therefore generate a new `node_modules/` for every subpackage.
15-
- Running the `build` script invokes the [considerably faster](https://github-production-user-asset-6210df.s3.amazonaws.com/3084745/266451348-e65fa63c-99c7-4bcf-950b-e2fe9408a942.png) `Bun.build` bundler, as opposed to running `tsc`.
16-
- Other incompatibilities which may be added to the project at any time
17-
18-
For this reason, while it should be possible to use npm, yarn, or pnpm with minor modifications to the builder, it is advised to install Bun.
19-
2011
## Building
2112

2213
This project depends on [`@livekit/rtc-node`](https://npmjs.com/package/@livekit/rtc-node), which itself depends on `libstdc++` version 6 being in PATH.
2314

2415
Install the project dependencies and run the build script:
2516
```sh
26-
$ bun install
17+
$ pnpm install
2718
$ cd agents
28-
$ bun run build
19+
$ pnpm build
2920
```
3021

3122
Your output will be in the `dist/` directory.

Diff for: agents/src/cli.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { version } from '.';
5+
import { version } from './version.js';
66
import { Option, Command } from 'commander';
7-
import { WorkerOptions, Worker } from './worker';
7+
import { WorkerOptions, Worker } from './worker.js';
88
import { EventEmitter } from 'events';
9-
import { log } from './log';
9+
import { log } from './log.js';
1010

1111
type CliArgs = {
1212
opts: WorkerOptions;

Diff for: agents/src/index.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
export * from './vad';
6-
export * from './plugin';
7-
export * from './version';
8-
export * from './job_context';
9-
export * from './job_request';
10-
export * from './worker';
11-
export * from './utils';
12-
export * from './log';
13-
export * as cli from './cli';
14-
export * as stt from './stt';
15-
export * as tts from './tts';
5+
export * from './vad.js';
6+
export * from './plugin.js';
7+
export * from './version.js';
8+
export * from './job_context.js';
9+
export * from './job_request.js';
10+
export * from './worker.js';
11+
export * from './utils.js';
12+
export * from './log.js';
13+
export * as cli from './cli.js';
14+
export * as stt from './stt/index.js';
15+
export * as tts from './tts/index.js';

Diff for: agents/src/ipc/job_main.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { IPC_MESSAGE, JobMainArgs, Message, Ping } from './protocol';
5+
import { IPC_MESSAGE, JobMainArgs, Message, Ping } from './protocol.js';
66
import { Room } from '@livekit/rtc-node';
77
import { EventEmitter, once } from 'events';
8-
import { JobContext } from '../job_context';
9-
import { log } from '../log';
8+
import { JobContext } from '../job_context.js';
9+
import { log } from '../log.js';
1010
import { ChildProcess, fork } from 'child_process';
1111
import { JobAssignment, ServerMessage } from '@livekit/protocol';
1212

Diff for: agents/src/ipc/job_process.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
import { Job } from '@livekit/protocol';
6-
import { IPC_MESSAGE, JobMainArgs, Message, Pong, StartJobResponse } from './protocol';
7-
import { runJob } from './job_main';
6+
import { IPC_MESSAGE, JobMainArgs, Message, Pong, StartJobResponse } from './protocol.js';
7+
import { runJob } from './job_main.js';
88
import { once } from 'events';
9-
import { log } from '../log';
9+
import { log } from '../log.js';
1010
import { Logger } from 'pino';
11-
import { AcceptData } from '../job_request';
11+
import { AcceptData } from '../job_request.js';
1212
import { ChildProcess } from 'child_process';
1313

1414
const START_TIMEOUT = 90 * 1000;

Diff for: agents/src/job_request.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
import { Job, ParticipantInfo, Room } from '@livekit/protocol';
6-
import { log } from './log';
6+
import { log } from './log.js';
77
import { EventEmitter } from 'events';
88

99
class AnsweredError extends Error {

Diff for: agents/src/stt/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
export { STT, SpeechEvent, SpeechEventType, SpeechStream } from './stt';
6-
export { StreamAdapter, StreamAdapterWrapper } from './stream_adapter';
5+
export { STT, SpeechEvent, SpeechEventType, SpeechStream } from './stt.js';
6+
export { StreamAdapter, StreamAdapterWrapper } from './stream_adapter.js';

Diff for: agents/src/stt/stream_adapter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { STT, SpeechEvent, SpeechEventType, SpeechStream } from './stt';
6-
import { VADEventType, VADStream } from '../vad';
5+
import { STT, SpeechEvent, SpeechEventType, SpeechStream } from './stt.js';
6+
import { VADEventType, VADStream } from '../vad.js';
77
import { AudioFrame } from '@livekit/rtc-node';
8-
import { AudioBuffer, mergeFrames } from '../utils';
8+
import { AudioBuffer, mergeFrames } from '../utils.js';
99

1010
export class StreamAdapterWrapper extends SpeechStream {
1111
closed: boolean;

Diff for: agents/src/stt/stt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
import { AudioFrame } from '@livekit/rtc-node';
6-
import { AudioBuffer } from '../utils';
6+
import { AudioBuffer } from '../utils.js';
77

88
export enum SpeechEventType {
99
START_OF_SPEECH = 0,

Diff for: agents/src/tts/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
export { TTS, SynthesisEvent, SynthesisEventType, SynthesizedAudio, SynthesizeStream } from './tts';
6-
export { StreamAdapter, StreamAdapterWrapper } from './stream_adapter';
5+
export {
6+
TTS,
7+
SynthesisEvent,
8+
SynthesisEventType,
9+
SynthesizedAudio,
10+
SynthesizeStream,
11+
} from './tts.js';
12+
export { StreamAdapter, StreamAdapterWrapper } from './stream_adapter.js';

Diff for: agents/src/tts/stream_adapter.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { TTS, SynthesisEvent, SynthesisEventType, SynthesizedAudio, SynthesizeStream } from './tts';
6-
import { SentenceStream, SentenceTokenizer } from '../tokenize';
5+
import {
6+
TTS,
7+
SynthesisEvent,
8+
SynthesisEventType,
9+
SynthesizedAudio,
10+
SynthesizeStream,
11+
} from './tts.js';
12+
import { SentenceStream, SentenceTokenizer } from '../tokenize.js';
713

814
export class StreamAdapterWrapper extends SynthesizeStream {
915
closed: boolean;

Diff for: agents/src/worker.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import os from 'os';
66
import { WebSocket } from 'ws';
7-
import { AvailRes, JobRequest } from './job_request';
7+
import { AvailRes, JobRequest } from './job_request.js';
88
import {
99
JobType,
1010
Job,
@@ -14,13 +14,13 @@ import {
1414
AvailabilityRequest,
1515
JobAssignment,
1616
} from '@livekit/protocol';
17-
import { AcceptData } from './job_request';
18-
import { HTTPServer } from './http_server';
19-
import { log } from './log';
20-
import { version } from './version';
17+
import { AcceptData } from './job_request.js';
18+
import { HTTPServer } from './http_server.js';
19+
import { log } from './log.js';
20+
import { version } from './version.js';
2121
import { AccessToken } from 'livekit-server-sdk';
2222
import { EventEmitter } from 'events';
23-
import { JobProcess } from './ipc/job_process';
23+
import { JobProcess } from './ipc/job_process.js';
2424

2525
const MAX_RECONNECT_ATTEMPTS = 10;
2626
const ASSIGNMENT_TIMEOUT = 15 * 1000;

Diff for: bun.lockb

-75.2 KB
Binary file not shown.

Diff for: examples/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"private": true,
33
"name": "livekit-agents-examples",
44
"type": "module",
5+
"scripts": {
6+
"build": "tsc",
7+
"lint": "eslint src"
8+
},
59
"devDependencies": {
610
"@types/bun": "latest"
711
},

Diff for: examples/minimal.ts renamed to examples/src/minimal.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { fileURLToPath } from 'url';
88
// your entry file *has* to include an exported function [entry].
99
// this file will be imported from inside the library, and this function
1010
// will be called.
11-
export const entry = async (_: JobContext) => {
11+
export const entry = async (job: JobContext) => {
1212
console.log('starting voice assistant...');
13-
13+
job;
1414
// etc
1515
};
1616

Diff for: examples/tts.ts renamed to examples/src/tts.ts

File renamed without changes.

Diff for: examples/tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["ESNext"],
4+
"target": "ESNext",
5+
"module": "ESNext",
6+
"moduleDetection": "force",
7+
"moduleResolution": "node",
8+
"allowJs": true,
9+
"strict": true,
10+
"skipLibCheck": true,
11+
"esModuleInterop": true,
12+
"outDir": "dist"
13+
},
14+
"include": ["**/*.ts"]
15+
}

Diff for: flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
in {
1818
devShell = with pkgs; mkShell {
19-
nativeBuildInputs = [ bun reuse ];
19+
nativeBuildInputs = [ nodejs nodePackages.pnpm reuse ];
2020
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib/";
2121
};
2222
}

Diff for: package.json

-4
This file was deleted.

Diff for: plugins/elevenlabs/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
export * from './tts';
5+
export * from './tts.js';

Diff for: plugins/elevenlabs/src/tts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
import { TTSModels } from './models';
5+
import { TTSModels } from './models.js';
66
import { log, tts } from '@livekit/agents';
77
import { RawData, WebSocket } from 'ws';
88
import { URL } from 'url';

0 commit comments

Comments
 (0)