Startup and project setup
本頁內容尚未翻譯。
How the bot starts
Section titled “How the bot starts”roundtable start first runs the checks that need no network: Bun, .env, the configuration, the plugins, the model login, and the public URL.
A failed check stops the start with the message roundtable doctor prints for it.
Then the host runs these steps in order:
-
Replacements and providers. Each plugin’s
replacesis applied, so the replaced plugin is dropped and the replacement stands where it stood. Then each provider slot is resolved from the plugin that fills it, or the core’s default. -
Database and migrations. The database is opened and every plugin’s migrations run, in plugin order.
-
Setup. Every plugin’s
setupruns, in plugin order. -
Linking. Tool tiers, hold rules, the session plan, the channel router, and the events are linked. From here
sessions(),conversations,surfaces,turnsanddashboard()work. -
Preflight. Every plugin’s
preflightruns. The Discord plugin composes the slash commands here, so a clash stops the start at this step. -
Services. Every service starts, plugin by plugin in plugin order. A plugin’s chat surfaces start before its own services.
-
HTTP. The listeners open.
-
Background starts. Every service’s
startInBackgroundruns without holding up the boot, and every plugin hearsserviceStartedas each ends.
Nothing reaches Discord or the listener unless steps 1 to 5 succeeded.
Plugin order
Section titled “Plugin order”Setup order is the built-in plugins first: memory, schedule-store, discord, modules, discord-admin, skills, agent-server, seeds.
An addon that is switched off is not in the list.
Then come your plugins, in the order of plugins in roundtable.config.ts.
The built-in schedules plugin comes last, so a due schedule fires only once everything it can reach is running.
Text that depends on the language
Section titled “Text that depends on the language”run() applies the host’s environment to the process before anything else: the locale, the time zone, and the assistant’s name.
So build a command or tool description in setup or later, never at import time.
One host runs per process, because the message catalog and the time zone are process-wide.
A second run() while one host is running is refused.
If a step fails, the host stops what it had started, closes the database pool, and rethrows. The process then exits non-zero.
How the bot stops
Section titled “How the bot stops”On SIGTERM or SIGINT the bot stops serving new work last:
-
It keeps serving until the channel queue is empty and no service reports
busy()work, for at most an hour. Whatever is left is logged and given up on. -
Every plugin hears
shutdown(left), while every service is still running. -
The HTTP listener closes, so no request reaches a service that has stopped.
-
Services stop in the reverse of the order they started.
-
The database pool closes.
TypeScript configuration
Section titled “TypeScript configuration”The package ships .ts source, so your compiler checks it with your project’s options.
The guide gives a full tsconfig.json that was tested against an installed tarball.
These are the points that matter:
- Set
moduleResolutiontobundler,moduletoPreserve, andtypesto["bun"]. - Turn on
strict,verbatimModuleSyntax,allowImportingTsExtensions, andnoEmit. - Keep
skipLibCheckon. Without it the tested example reports 97 dependency-declaration errors. - Keep
exactOptionalPropertyTypesandnoPropertyAccessFromIndexSignatureoff. Turning either on produces package-source errors even withskipLibCheck. - Install TypeScript and
@types/bunas development dependencies, as the generated project does.
Type-only exports need import type when verbatimModuleSyntax is on.
Copy the whole file from Consumer TypeScript configuration.
Develop the core and a host together
Section titled “Develop the core and a host together”A host pins an exact pi-roundtable version, so a change to the core reaches it only after a release.
To try a change first, link your checkout:
# in the pi-roundtable checkoutbun link# in the hostbun link pi-roundtableThe host now imports the checkout’s source, so edits show at once, and the host’s bun run typecheck and bun test run against them.
A linked checkout resolves its own dependencies from its own node_modules, so a host’s overrides do not reach it.
When the change is done, release the core, set the host’s pi-roundtable to the new exact version, and run bun install to replace the link with the published package.
Then run the host’s checks once more against what was published.
For the full text, see What happens when the bot starts and stops and Developing the core and a host together.