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.
Read an empty example Bot PORT as unset, so NaN never reaches Bun.serve (#411)
Bartoke45f3f8f56df
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 399f68d1..5428ad86 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,9 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.## Unreleased+### Example LangGraph and Mastra Bots no longer bind an ephemeral port on empty `PORT=`++An empty `PORT=` in compose or `.env` used to become `NaN` for those two example processes, so they listened on a random port while docs still named 4300/4400. They now use the same `listenPort` helper as `agent-bot`: empty is the documented default, and a prefix typo refuses to start.### An empty app port is the default, not a random one`APP_PORT=` and `SERVER_PORT=` in a compose file or leftover `.env` used to become `NaN` for the Vitediff --git a/examples/langgraph-bot/src/index.ts b/examples/langgraph-bot/src/index.tsindex e8308cc1..8fd78dd1 100644--- a/examples/langgraph-bot/src/index.ts+++ b/examples/langgraph-bot/src/index.ts@@ -10,6 +10,7 @@ import {import { Annotation, END, START, StateGraph } from "@langchain/langgraph";import { ChatOpenAI } from "@langchain/openai";import { serve } from "bun";+import { listenPort } from "../../../shared/listen-port";/*** A Bot written in LangGraph.@@ -26,7 +27,12 @@ import { serve } from "bun";* `computer_navigate` and still drives a governed browser.*/-const PORT = Number.parseInt(process.env.PORT ?? "4300", 10);+const resolvedPort = listenPort(process.env.PORT, 4300);+if (!resolvedPort.ok) {+ console.error(resolvedPort.reason);+ process.exit(1);+}+const PORT = resolvedPort.port;const MODEL = process.env.BOT_MODEL ?? "gpt-5.5";/*** `gpt-5.6-*` rejects function tools on `/v1/chat/completions` and needs the Responses API, whichdiff --git a/examples/mastra-bot/src/index.ts b/examples/mastra-bot/src/index.tsindex c39b79c3..944bc66b 100644--- a/examples/mastra-bot/src/index.ts+++ b/examples/mastra-bot/src/index.ts@@ -3,6 +3,7 @@ import { EventEncoder } from "@ag-ui/encoder";import { openai } from "@ai-sdk/openai";import { Agent } from "@mastra/core/agent";import { serve } from "bun";+import { listenPort } from "../../../shared/listen-port";/*** A Bot written in Mastra.@@ -16,7 +17,12 @@ import { serve } from "bun";* as `agent-bot` and the LangGraph example.*/-const PORT = Number.parseInt(process.env.PORT ?? "4400", 10);+const resolvedPort = listenPort(process.env.PORT, 4400);+if (!resolvedPort.ok) {+ console.error(resolvedPort.reason);+ process.exit(1);+}+const PORT = resolvedPort.port;const MODEL = process.env.BOT_MODEL ?? "gpt-5.5";/*** `gpt-5.6-*` rejects function tools on `/v1/chat/completions` and needs the Responses API, which