import { H as HandlerConfig } from './handlers-D9ngfDB-.js'; import '@byollm/protocol'; import './store-BkDHRir0.js'; /** * `@byollm/server/next` — the one-file Next.js mount. * * Drop this in `app/api/byollm/[...route]/route.ts`: * * ```ts * import { createHandler } from "@byollm/server/next"; * import { siteKeysFromEnv } from "@byollm/server"; * import { getStore } from "@/lib/byollm"; * * export const { POST } = createHandler(() => ({ * store: getStore(), * siteKeys: siteKeysFromEnv("BYOLLM_SITE_KEYS"), * verificationUrl: "https://your-app.com/settings/runners", * // Next serves this route under /api, so say so. The handler matches the * // full path, not a suffix, and will 404 without it. * basePath: "/api/byollm", * })); * ``` * * **Pass a function, not an object.** `next build` imports every route module * to collect page data, in an environment that has no secrets — so a config * *object* means the store and the site keys are constructed at build time, * and the build fails on the credentials it cannot have. A function is not * called until the first request, so importing this module does nothing. * * An object still works, for a store that needs no secrets to construct. It is * the second form because it is the one that fails in production and not in * development, which is the wrong way round for a default. * * **Then pair against that same path**: `byollm connect https://your-app.com/api`. * The daemon appends `/byollm/` to whatever origin it is given, so * connecting to the bare domain reaches `/byollm/claim` and finds nothing. * This is the first thing an integrator gets wrong, and it used to fail as a * silent 404 — the handler matched on the last path segment alone, so nothing * ever checked where it was mounted. * * To serve at `/byollm` instead, move the route to * `app/byollm/[...route]/route.ts`, drop `basePath`, and pair against the bare * domain. * * That is the whole protocol surface. The app-facing half — enqueue, approve * a pairing, read a result — is {@link ByollmApp} from `@byollm/server`. * * @packageDocumentation */ /** What this mount needs, plus where it is mounted. */ type NextHandlerConfig = HandlerConfig & { /** Where this route is mounted. Next users almost always want * `"/api/byollm"`; see the example above. */ readonly basePath?: string; }; declare function createHandler(config: NextHandlerConfig | (() => NextHandlerConfig)): { POST: (request: Request) => Promise; /** Present so a stray GET gets a clear 405 rather than a framework 404. */ GET: (request: Request) => Promise; /** Route handlers must not be cached — every call mutates lease state. */ dynamic: "force-dynamic"; }; export { HandlerConfig, type NextHandlerConfig, createHandler };