Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

Start the app and the server from `bun run dev`, and leave the routines worker to start.sh (#468)

Vaibhav Zope8819f1801baf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24a3ce1e..6574458d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,16 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
## Unreleased
+### `bun run dev` no longer starts a routines worker that cannot start
+
+`bun run dev` fanned out across every workspace, and one of them is the routines worker. That worker
+is handed `DATABASE_URL`, `SERVER_INTERNAL_URL` and `WORKER_SHARED_SECRET` by `scripts/start.sh` and
+by nothing else, so the copy this command started read none of them and threw at boot on every run,
+printing a stack trace in between the app's output and the server's. It has never started
+successfully. The command now starts the app and the server, which is what `README.md` and
+`docs/development.md` already say it does. Routines are unaffected: `scripts/start.sh` starts the
+worker exactly as before, and on Kubernetes the CronJob does.
+
### Double-clicking works while a person is driving a Bot's browser
A double click was sent to the Bot's browser as two separate first clicks, because every press said
diff --git a/package.json b/package.json
index c365827c..04f97d10 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
],
"scripts": {
"build": "bun run generate:app-config && bun run --filter '*' build",
- "dev": "bun run generate:app-config && bun run --filter '*' --parallel dev",
+ "dev": "bun run generate:app-config && bun run --filter app --filter server --parallel dev",
"generate:app-config": "bun --env-file=.env scripts/generate-app-config.ts",
"format": "bunx biome format --write .",
"format:check": "bunx biome format .",
diff --git a/tests/workspace.test.ts b/tests/workspace.test.ts
index aacea898..17538c2f 100644
--- a/tests/workspace.test.ts
+++ b/tests/workspace.test.ts
@@ -12,17 +12,56 @@ function packageManifest(path: string) {
};
}
+function rootManifest() {
+ return JSON.parse(
+ readFileSync(join(repositoryRoot, "package.json"), "utf8"),
+ ) as { workspaces: string[]; scripts: Record<string, string> };
+}
+
+function packagesStartedBy(script: string, workspaces: string[]): string[] {
+ const filters = [
+ ...script.matchAll(/--filter\s+(?:'([^']*)'|"([^"]*)"|(\S+))/g),
+ ].map((match) => match[1] ?? match[2] ?? match[3]);
+ return workspaces.filter((workspace) =>
+ filters.some((filter) => filter === "*" || filter === workspace),
+ );
+}
+
describe("OpenBot workspace", () => {
test("defines the app, server, and worker packages", () => {
- const rootManifest = JSON.parse(
- readFileSync(join(repositoryRoot, "package.json"), "utf8"),
- ) as { workspaces: string[] };
+ const manifest = rootManifest();
- expect(rootManifest.workspaces).toEqual(["app", "server", "worker"]);
+ expect(manifest.workspaces).toEqual(["app", "server", "worker"]);
- for (const packageName of rootManifest.workspaces) {
+ for (const packageName of manifest.workspaces) {
expect(existsSync(join(repositoryRoot, packageName))).toBe(true);
expect(packageManifest(packageName).name).toBe(packageName);
}
});
+
+ test("dev starts the app and the server, and not the routines worker", () => {
+ const manifest = rootManifest();
+
+ expect(
+ packagesStartedBy(manifest.scripts.dev, manifest.workspaces),
+ ).toEqual(["app", "server"]);
+ });
+
+ test("build still covers every workspace, including the worker", () => {
+ const manifest = rootManifest();
+
+ expect(
+ packagesStartedBy(manifest.scripts.build, manifest.workspaces),
+ ).toEqual(manifest.workspaces);
+ });
+
+ test("scripts/start.sh is what starts the routines worker", () => {
+ const startScript = readFileSync(
+ join(repositoryRoot, "scripts", "start.sh"),
+ "utf8",
+ );
+
+ expect(startScript).toContain("bun worker/src/index.ts");
+ expect(startScript).toContain("WORKER_SHARED_SECRET=");
+ });
});