eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
87 lines (86 loc) • 3.72 kB
TypeScript
import type { NextConfig } from "next";
/**
* Default private route namespace for hosting eve as a separate experimental
* Vercel service behind the Next.js app. {@link WithEveOptions.servicePrefix}
* defaults to this value.
*/
export declare const EVE_NEXT_SERVICE_PREFIX = "/_eve_internal/eve";
type ArrayElement<T> = T extends readonly (infer TElement)[] ? TElement : never;
type NextRewrites = Awaited<ReturnType<NonNullable<NextConfig["rewrites"]>>>;
/**
* Next.js rewrite rule that {@link withEve} emits.
*/
export type EveNextRewriteRule = ArrayElement<NextRewrites>;
/**
* Resolved return type of a Next.js `rewrites` function: an array of rules, or
* the sectioned `{ beforeFiles, afterFiles, fallback }` object.
*/
export type EveNextRewrites = NextRewrites;
/**
* Sectioned Next.js rewrite rules.
*/
export type EveNextRewriteSections = Extract<NextRewrites, {
readonly afterFiles?: EveNextRewriteRule[];
readonly beforeFiles?: EveNextRewriteRule[];
readonly fallback?: EveNextRewriteRule[];
}>;
/**
* Alias of Next.js's `NextConfig`, the config object form {@link withEve}
* accepts (the other being {@link EveNextConfigFunction}).
*/
export type EveNextConfig = NextConfig;
/**
* Structural shape of a Next.js config function: receives the build `phase` and
* a `context` containing `defaultConfig`, and returns a config (or a promise of
* one). This is the form {@link withEve} returns.
*/
export type EveNextConfigFunction<TConfig extends EveNextConfig = EveNextConfig> = (phase: string, context: {
readonly defaultConfig: TConfig;
}) => TConfig | Promise<TConfig>;
/**
* Next.js config input that {@link withEve} accepts.
*/
export type EveNextConfigInput<TConfig extends EveNextConfig = EveNextConfig> = EveNextConfigFunction<TConfig> | TConfig;
/**
* Options for {@link withEve}.
*/
export interface WithEveOptions {
/**
* Maximum time in milliseconds to wait for the eve development server to
* start, including waiting for another Next.js process to start it. Defaults
* to 180000 (three minutes).
*/
readonly devServerTimeoutMs?: number;
/**
* Path to the eve application root, relative to `process.cwd()` unless
* absolute. Defaults to the Next.js app root.
*/
readonly eveRoot?: string;
/**
* Build command for the generated eve Vercel service. Defaults to `eve build`.
* Use this when the eve service needs project-specific prework before the
* framework build, without changing the Next.js service build command.
*/
readonly eveBuildCommand?: string;
/**
* Private Vercel service prefix for the eve deployment. Defaults to
* {@link EVE_NEXT_SERVICE_PREFIX} (`/_eve_internal/eve`). `withEve` normalizes
* the prefix (adds a leading slash, strips trailing slashes) and rejects a
* prefix that resolves to the root route. The prefix must match the eve
* service's mount in Vercel Build Output config.
*/
readonly servicePrefix?: string;
}
/**
* Wraps a Next.js config so same-origin eve endpoints proxy to a separate eve
* service.
*
* In development, starts `eve dev --no-ui --port 0` for the eve app and
* rewrites eve protocol endpoints to that local URL. In Vercel production,
* rewrites to the resolved private eve service prefix.
* Outside Vercel production, serves an existing `.output/server/index.mjs` build
* on a stable local port when present; otherwise set `EVE_NEXT_PRODUCTION_ORIGIN`
* to the origin serving the eve service namespace.
*/
export declare function withEve<TConfig extends EveNextConfig>(configOrFunction: EveNextConfigInput<TConfig>, options?: WithEveOptions): EveNextConfigFunction<TConfig>;
export {};